﻿using Newtonsoft.Json;

namespace Entity
{
    /// <summary>
    /// 拼团表
    /// </summary>
    public class TeamBuy : BaseEntity
    {

        /// <summary>
        /// 拼团标题
        /// </summary>
        public string? Title { get; set; }

        /// <summary>
        /// 拼团描述
        /// </summary>
        public string? Description { get; set; }

        /// <summary>
        /// 所属商户
        /// </summary>
        public int StoreId { get; set; }

        /// <summary>
        /// 代理商
        /// </summary>
        public int ProxyId { get; set; }

        /// <summary>
        /// 团购商品
        /// </summary>
        public int ProductId { get; set; }

        /// <summary>
        /// 商品信息
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(ProductId))]
        public TeamBuyProduct? Product { get; set; }

        /// <summary>
        /// 商家信息
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(StoreId))]
        public Entity.Store? Store { get; set; }

        /// <summary>
        /// 发起商户编号
        /// </summary>
        public int CratedUserId { get; set; }

        /// <summary>
        /// 最大人数
        /// </summary>
        public int MaxNum { get; set; }

        /// <summary>
        /// 当前人数
        /// </summary>
        public int CurrentNum { get; set; }

        /// <summary>
        /// 拼团价格
        /// </summary>
        public decimal GroupPrice { get; set; }

        /// <summary>
        /// 拼团状态
        /// </summary>
        public TeamBuyState State { get; set; }

        /// <summary>
        /// 拼团结束时间
        /// </summary>
        public DateTime EndTime { get; set; } = Convert.ToDateTime("1900-01-01");

        /// <summary>
        /// 是否加入过机器人
        /// </summary>
        [JsonIgnore]
        public bool JoinRobot { get; set; } = false;

    }

    /// <summary>
    /// 拼团状态
    /// </summary>
    public enum TeamBuyState
    {
        /// <summary>
        /// 进行中
        /// </summary>
        进行中,

        /// <summary>
        /// 拼团结束
        /// </summary>
        已结束
    }
}
